package Element.Geom;

import java.awt.*;
import Element.*;

public class TwoNodeElemGeom extends AbsElemGeom implements Cloneable {

    public TwoNodeElemGeom() {}

    // This is used by creating an element in drawing panel from the starting pt;
    // This method will be overloadded by LineGeom, BusGeom & ThreeNodeElemGeom;
    // For all other elements, this will be actually used for initialization
    public void initFromScreen(String n, Point pt){
        init(n);
        rotation=1;
        setNode1FromScreen( pt );  //from screen
        findNode2BasedonDir(true); // default size
        calcFrame();
    }

    // this is used by reading info from an DB for two-node elem becoz
    // starting and ending points are all defined in an DB
    public void initFromDB(String n, String desc, int r, int LTC,
                           boolean sn, boolean sd, int[][] si, Point pt,
                           Point pt2){
        init(n, desc, r, LTC, sn, sd, si);
        setNode1FromStored( pt );
        setNode2FromStored( pt2 );
        calcFrame();
    }

    //not a real implementation; real implementation is in the inner class of elements
    //public void draw(Graphics g){}

    public Object clone(){
        TwoNodeElemGeom created = new TwoNodeElemGeom();
        // all ref. in created has been instantiated such as frame, conn1,conn2, childList

        this.copyTo( created);// copy AbsElemGeom attributes to created

        return created;
    }
}